package com.lovo.doudizhu;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Dapai {
    public static List list1 = new ArrayList();
    public static List list2 = new ArrayList();
    public static List list3 = new ArrayList();
    public static List list4 = new ArrayList();
    public static ArrayList list = new ArrayList();

    public static void main(String[] args) {

        Dapai dapai = new Dapai();
        dapai.init();
        dapai.xipai();
        dapai.fapai();
        dapai.paixu();
    }

    //初始化
    public void init() {
        String[] color = {"♠", "♥", "♦", "♣"};//花色
        String[] num = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};//点数
        for (int i = 0; i < color.length; i++) {//huase
            for (int j = 0; j < num.length; j++) {
                Card card = new Card(num[j], color[i], j);
                list.add(card);//花色在前
            }
        }
        list.add(new Card("小王", "", 13));
        list.add(new Card("大王", "", 14));
    }

    //洗牌
    public void xipai() {
        Collections.shuffle(list);
    }

    //发牌
    public void fapai() {
        list1 = list.subList(0, 17);
        list2 = list.subList(17, 34);
        list3 = list.subList(34, 51);
        list4 = list.subList(51, 54);
        System.out.println("玩家1" + list1);
        System.out.println("玩家2" + list2);
        System.out.println("玩家3" + list3);
        System.out.println("底牌" + list4);
    }

    public void paixu() {
        list1.sort(new MyComparator());
        list2.sort(new MyComparator());
        list3.sort(new MyComparator());
        System.out.println("玩家1" + list1);
        System.out.println("玩家2" + list2);
        System.out.println("玩家3" + list3);
        System.out.println("底牌" + list4);
    }
}
